package com.h1909A.weinfo.model;

import com.h1909A.weinfo.base.BaseModel;
import com.h1909A.weinfo.bean.Bean;
import com.h1909A.weinfo.bean.NaviBean;
import com.h1909A.weinfo.net.ApiService;
import com.h1909A.weinfo.net.HttpUtil;
import com.h1909A.weinfo.net.ResultCallBack;
import com.h1909A.weinfo.net.ResultSubscriber;
import com.h1909A.weinfo.net.RxUtils;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.ResourceSubscriber;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;


//网络框架,Rxjava+Retrofit+okhttp
//okhttp:日志拦截器:4行; 缓存
//

public class MainModel extends BaseModel {
    public void getData(final ResultCallBack<NaviBean> callBack) {
        addDisposable(
                HttpUtil.getInstance()
                        .getWanService()
                        .getNavi()
                        .compose(RxUtils.<NaviBean>rxSchedulerHelper())//切换观察者和被观察者的线程
                        .subscribeWith(new ResultSubscriber<NaviBean>() {
                            @Override
                            public void onNext(NaviBean naviBean) {
                                callBack.onSuccess(naviBean);
                            }
                        })
        );
    }
}
